# -*- coding: utf-8 -*-
import talib
import sys
import numpy as np
import matplotlib.pyplot as plt
from gm.api import *
import os
import talib


class 整百数的分析():
    def __init__(self, data=None):
        pass

    def 是否接近整百(self):
        pass

    def 先前的数据的走势是否明朗(self):
        pass

    def 止损止盈(self):
        止盈 = 60
        止损 = 40
        pass

    def 是否购买(self, data=None, 周期=60):
        # 如果当前要破100就下单目标一百止损22
        当前MA方向 = 0

        当前MA的是否稳定 = None
        if 当前MA方向 > 0:
            return {'下单': '买入', '止盈': 5, '止损': 6}

    def 当前风险警告(self):
        pass


class 均线上下分析():
    def __init__(self):
        pass

    def 先前的数据的走势是否明朗(self):
        pass

    def 止损止盈(self):
        止盈 = 60
        止损 = 40
        pass

    def 是否购买(self, data=None, 周期=3600):
        MA = talib.MA(data['close'], timeperiod=周期)

        print(list(MA)[-1], list(data['close'])[-1])
        # MA=list(MA)
        # data=list(data['close'])
        if list(MA)[-1] <list(data['close'])[-1]-40:
            return 'buy'
        if list(MA)[-1] >list(data['close'])[-1]+40:
            return 'sell'

        # 逆向
        # if list(MA)[-1] >list(data['close'])[-1]-40:
        #     return 'buy'
        # if list(MA)[-1] <list(data['close'])[-1]+40:
        #     return 'sell'

    def 当前风险警告(self):
        pass
